package com.situ.mall.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.situ.mall.common.entity.Member;
import com.situ.mall.common.mapper.MemberMapper;
import com.situ.mall.common.service.IMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.situ.mall.common.util.RequestUtil;
import com.situ.mall.common.util.StringUtil;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商城会员 服务实现类
 * </p>
 *
 * @author kkkkkk
 * @since 2023-09-15
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService {

    @Override
    public boolean check(String username, String password) {
        Member m = baseMapper.selectOne(new LambdaQueryWrapper<Member>().eq(Member::getUsername, username));
        boolean b = m != null && m.getPassword().equals(StringUtil.md5(password));
        if (b) {
            RequestUtil.setCurrent(m);
        }
        return b;
    }
}
